<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      width: 250px;
      height: 400px;
      background-color: #6ff;
      position: fixed;
      right: 10px;
      bottom: 10px;
    }

    .close {
      line-height: 16px;
      position: absolute;
      right: 0;
      /* transform: translateY(-100%); */
      top: 0;
      padding: 5px;
      background-color: #f00;
    }
  </style>
</head>

<body>

</body>
<script>
  function fn() {
    var box = document.createElement("div");
    box.setAttribute("class", "box");
    document.body.appendChild(box);


    var tips = document.createElement("div");
    tips.setAttribute("class", "tips");
    tips.innerHTML = "距离广告关闭还有10秒";
    box.appendChild(tips);

    var closeBtn = document.createElement("div");
    closeBtn.setAttribute("class", "closeBtn")
    closeBtn.innerHTML = "X";
    box.appendChild(closeBtn);

    closeBtn.onclick = function () {
      clearTimeout(delayTimer);
      clearInterval(timer);
      box.remove();
      showAdver(5000);
    }

  }
  fn();

</script>

</html>